package com.dl.mall.config.alipay;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 阿里支付宝配置类
 * @author DL
 * @create 2022-04-13 12:50
 */
@Configuration
public class AliPayConfig {

    @Resource
    private AliPayProperties aliPayProperties;

    private static final String JSON = "json";
    private static final String RSA2 = "RSA2";
    private static final String CHARSET = "UTF-8";

    public AlipayClient getAliPayClient(){
        return new DefaultAlipayClient(
                aliPayProperties.getGatewayUrl(),
                aliPayProperties.getAppId(),
                aliPayProperties.getPrivateKey(),
                JSON,
                CHARSET,
                aliPayProperties.getPublicKey(),
                RSA2
        );
    }


}
